package controllers;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

import models.Topic;


public class OrderTopicByRating implements Comparator<Topic> {

	@Override
	public int compare(Topic u1, Topic u2) {
		if(u1.topicRating < u2.topicRating)
			return -1;
		if(u1.topicRating > u2.topicRating)
			return 1;
		return 0;
	}


	public static void sort(ArrayList<Topic> topics){
		Collections.sort(topics, new OrderTopicByRating());
	}

}
